package com.chenjun.core.service.oa.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chenjun.common.model.DataGridModel;
import com.chenjun.core.dao.generator.entity.OaDictLeaveType;
import com.chenjun.core.dao.generator.mapper.OaDictLeaveTypeMapper;
import com.chenjun.core.dao.module.OaDictLeaveTypeRelationMapper;
import com.chenjun.core.service.oa.LeaveTypeManagerService;

@Service
@Transactional
public class LeaveTypeManagerServiceImpl implements LeaveTypeManagerService {
	
	@Resource
	private OaDictLeaveTypeMapper leaveTypeMapper;
	
	@Resource
	private OaDictLeaveTypeRelationMapper leaveTypeRelactionMapper;

	@Override
	public OaDictLeaveType get(Integer id) {
		return leaveTypeMapper.selectByPrimaryKey(id);
	}

	@Override
	public int delete(Integer id) {
		return leaveTypeMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int createOrUpdate(OaDictLeaveType record) {
		int rows = 0;
		if (record.getId() == null) {
			rows = leaveTypeMapper.insert(record);
		} else {
			rows = leaveTypeMapper.updateByPrimaryKeySelective(record);
		}
		return rows;
	}

	@Override
	public List<OaDictLeaveType> doListByCondition(DataGridModel param) {
		return leaveTypeRelactionMapper.selectByCondition(param);
	}

}
